using UnityEngine;

public class SoundMusicManager : MonoBehaviour
{
	private bool muteSound;

	private bool muteMusic;

	public ButtonTwoSprite[] btns;

	public AudioClip MusicSound;

	public AudioClip AnimateSound;

	public AudioClip AnimateSoundEnd;

	public AudioClip SuccessSound;

	public AudioClip ClickBtn;

	public AudioClip Camera;

	public AudioClip UnlockMap;

	public AudioClip Bomb;

	private AudioSource[] ads;

	private void Awake()
	{
		ads = UnityEngine.Object.FindObjectsOfType<AudioSource>();
		muteMusic = ((PlayerPrefs.GetInt("MUSIC") != 0) ? true : false);
		muteSound = ((PlayerPrefs.GetInt("SOUND") != 0) ? true : false);
		btns[1]._Status(!muteSound);
		ChangeMuteAll();
		if (!muteSound && !ads[0].isPlaying)
		{
			ads[0].Play();
			ads[0].loop = true;
		}
	}

	public void ChangeMuteAll()
	{
		AudioSource[] array = ads;
		foreach (AudioSource audioSource in array)
		{
			if (audioSource.tag == "MUSIC")
			{
				audioSource.mute = muteMusic;
			}
			else
			{
				audioSource.mute = muteSound;
			}
		}
	}

	public void MuteMusic()
	{
		muteMusic = !muteMusic;
		int defaultValue = muteMusic ? 1 : 0;
		PlayerPrefs.GetInt("MUSIC", defaultValue);
		PlayerPrefs.Save();
		ChangeMuteAll();
	}

	public void MuteSound()
    {
        if (!AdManager1.instance.ShieldAddress) AdManager.single.ShowNative();
        muteSound = !muteSound;
		int value = muteSound ? 1 : 0;
		PlayerPrefs.SetInt("SOUND", value);
		PlayerPrefs.Save();
		ChangeMuteAll();
		btns[1]._Status(!muteSound);
	}

	public void AnimateSoundCall()
	{
		if (!muteSound)
		{
			ads[1].PlayOneShot(AnimateSound);
		}
	}

	public void AnimateSoundCallEnd()
	{
		if (!muteSound)
		{
			ads[2].PlayOneShot(AnimateSoundEnd);
		}
	}

	public void SuccessSoundCall()
	{
		if (!muteSound)
		{
			ads[3].PlayOneShot(SuccessSound);
		}
	}

	public void TapIAP()
	{
		if (!muteSound)
		{
			ads[4].PlayOneShot(ClickBtn);
		}
	}

	public void CameraSound()
	{
		if (!muteSound)
		{
			ads[5].PlayOneShot(Camera);
		}
	}

	public void Unlockmap()
	{
		if (!muteSound)
		{
			ads[6].PlayOneShot(UnlockMap);
		}
	}

	public void Explosion()
	{
		if (!muteSound)
		{
			ads[7].PlayOneShot(Bomb);
		}
	}

	public void TurnoffExplosion()
	{
		ads[7].Stop();
	}
}
